package inTheArea.demo;

import presence.demo.R;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;


public class InTheAreaMainActivity extends Activity {
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.in_the_area_menu);
		addButtonListeners();
	}	

	
	public void addButtonListeners() {	 
		ImageButton imgButtonPlaces = (ImageButton) findViewById(R.id.toilet_btn);
		ImageButton imgButtonToilet = (ImageButton) findViewById(R.id.places_btn);
	 
		
		imgButtonToilet.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View view) {
				Intent inArea;
				PackageManager manager = getPackageManager();
				try {
					inArea = manager.getLaunchIntentForPackage("in.bitcode.placesaroundme");
				    if (inArea == null)
				        throw new PackageManager.NameNotFoundException();
				    inArea.addCategory(Intent.CATEGORY_LAUNCHER);
				    startActivity(inArea);
				} catch (PackageManager.NameNotFoundException e) {

				}		
			}
		}); 
		
		imgButtonPlaces.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View view) {
				Intent places;
				PackageManager manager = getPackageManager();
				try {
					places = manager.getLaunchIntentForPackage("com.bto.toilet");
				    if (places == null)
				        throw new PackageManager.NameNotFoundException();
				    places.addCategory(Intent.CATEGORY_LAUNCHER);
				    startActivity(places);
				} catch (PackageManager.NameNotFoundException e) {

				}		
			}
		}); 
		
	}

	

}
